import axios from 'axios';
import { API_GAME_URL } from '@/config/api';
import { AnyObject, HttpResponse } from '@/types/global';
import { GameRule } from '@/types/game';

const ROOT_URL = `${API_GAME_URL}/rule`;

export function createGameRule(gameRule: AnyObject) {
  return axios.post(`${ROOT_URL}/create`, gameRule);
}

export function updateGameRule(gameRule: AnyObject) {
  return axios.put(`${ROOT_URL}/update`, gameRule);
}

export function deleteGameRule(id: number) {
  return axios.delete(`${ROOT_URL}/${id}`);
}

export function getGameRuleList() {
  return axios.get<HttpResponse<GameRule[]>>(`${ROOT_URL}/list`);
}
